package com.bc.bczbweb.controller;

import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.common.JsonResult;
import com.bc.bcapi.service.T_Project_acceptsService;
import com.bc.bcmodel.domain.T_Project_acceptsModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigInteger;

import org.springframework.web.bind.annotation.RequestMethod;
import com.bc.bccore.util.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
@RequestMapping("t_project_accepts")
public class T_Project_acceptsController extends BaseController {
    @Autowired
    T_Project_acceptsService t_Project_acceptsService;

    @RequestMapping("list")
    public ModelAndView list() {
        ModelAndView view = super.baseView("列表", "t_project_accepts/list");
        return view;
    }

    @RequestMapping(value = "listdo", method = RequestMethod.POST)
    public ModelAndView listdo(T_Project_acceptsModel req) {
        ModelAndView view = super.baseViewAjax("列表", "t_project_accepts/listdo");
        PageInfo<T_Project_acceptsModel> pageInfo = t_Project_acceptsService.getList(req);
        view.addObject("data", pageInfo.getList());
        view.addObject("page", PageHelper.GetAjaxHtml(pageInfo, "javascript:loadpage(##);"));
        return view;
    }

    @RequestMapping("add")
    public ModelAndView add(BigInteger id) {
        String title = "添加";
        ModelAndView view = super.baseView(title, "t_project_accepts/add");
        T_Project_acceptsModel data = null;
        if (id.intValue() > 0) {
            title = "编辑";
            T_Project_acceptsModel model = new T_Project_acceptsModel();
            model.setId(id);
            data = t_Project_acceptsService.findByNamedParam(model);
        }
        view.addObject("data", data);
        view.addObject("title", title);
        return view;
    }
}